package com.xqb.modules.controller.study;

import com.xqb.common.annotation.Log;
import com.xqb.common.core.controller.BaseController;
import com.xqb.common.core.domain.AjaxResult;
import com.xqb.common.core.page.TableDataInfo;
import com.xqb.common.enums.BusinessType;
import com.xqb.common.utils.poi.ExcelUtil;
import com.xqb.modules.domain.po.StdPointsBoardSeason;
import com.xqb.modules.service.IStdPointsBoardSeasonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 赛季积分榜Controller
 * 
 * @author xqb
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/study/points_board_season")
public class StdPointsBoardSeasonController extends BaseController
{
    @Autowired
    private IStdPointsBoardSeasonService stdPointsBoardSeasonService;

    /**
     * 查询赛季积分榜列表
     */
    @PreAuthorize("@ss.hasPermi('study:points_board_season:list')")
    @GetMapping("/list")
    public TableDataInfo list(StdPointsBoardSeason stdPointsBoardSeason)
    {
        startPage();
        List<StdPointsBoardSeason> list = stdPointsBoardSeasonService.selectStdPointsBoardSeasonList(stdPointsBoardSeason);
        return getDataTable(list);
    }

    /**
     * 导出赛季积分榜列表
     */
    @PreAuthorize("@ss.hasPermi('study:points_board_season:export')")
    @Log(title = "赛季积分榜", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StdPointsBoardSeason stdPointsBoardSeason)
    {
        List<StdPointsBoardSeason> list = stdPointsBoardSeasonService.selectStdPointsBoardSeasonList(stdPointsBoardSeason);
        ExcelUtil<StdPointsBoardSeason> util = new ExcelUtil<StdPointsBoardSeason>(StdPointsBoardSeason.class);
        util.exportExcel(response, list, "赛季积分榜数据");
    }

    /**
     * 获取赛季积分榜详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:points_board_season:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stdPointsBoardSeasonService.selectStdPointsBoardSeasonById(id));
    }

    /**
     * 新增赛季积分榜
     */
    @PreAuthorize("@ss.hasPermi('study:points_board_season:add')")
    @Log(title = "赛季积分榜", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StdPointsBoardSeason stdPointsBoardSeason)
    {
        return toAjax(stdPointsBoardSeasonService.insertStdPointsBoardSeason(stdPointsBoardSeason));
    }

    /**
     * 修改赛季积分榜
     */
    @PreAuthorize("@ss.hasPermi('study:points_board_season:edit')")
    @Log(title = "赛季积分榜", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StdPointsBoardSeason stdPointsBoardSeason)
    {
        return toAjax(stdPointsBoardSeasonService.updateStdPointsBoardSeason(stdPointsBoardSeason));
    }

    /**
     * 删除赛季积分榜
     */
    @PreAuthorize("@ss.hasPermi('study:points_board_season:remove')")
    @Log(title = "赛季积分榜", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stdPointsBoardSeasonService.deleteStdPointsBoardSeasonByIds(ids));
    }
}
